/*
 * @Description:
 * @Author:
 * @Date: 2024-12-07 12:56:35
 * @LastEditTime: 2024-12-07 21:40:01
 * @LastEditors: XXX
 */
import { useStore } from '@/store'
import HttpClient, { type HttpClientConfig } from 'axios-mapper'
import networkConfig from '@/config/default/net.config'

const https = (hasToken: Boolean = true) => {
  const store = useStore()

  const config: HttpClientConfig = {
    baseURL: networkConfig.host,
    headers: {
      token: hasToken ? store.state.user.token : ''
    }
  }

  return new HttpClient(config)
}

export default https
